<template>
  <div class="bigbox">
    <div class="topbox">
      <div>
        <el-date-picker
        size="small"
          v-model="value1"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </div>
      <div class="button"><button>查询</button></div>
    </div>
    <div class="bodybox">
      <div class="table">
            <template>
              <el-table
              v-loading="loading"
              height="calc(100% - 1px)"
              :data="tableData"
              style="width: 100%"
              border
              id="exportTabyong"
              ref="table"
              size="medium"
              :header-cell-style="{'text-align':'center',background:'#f5f5f5'}"
                >
                <el-table-column
                  fixed
                  label="序号"
                  type="index"
                  width="100">
                </el-table-column>
                <el-table-column
                fixed
                  prop="eventLevelName"
                  label="告警等级"
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="orgName"
                  label="用电企业"
                  width="150">
                </el-table-column>
                <el-table-column
                  prop="switchRoom"
                  label="配电房/屏柜"
                  width="150">
                </el-table-column>
                <el-table-column
                  prop="devName"
                  label="设备名称"
                  width="210">
                </el-table-column>
                <el-table-column
                  prop="soeid"
                  label="告警信号"
                  width="150">
                </el-table-column>
                <el-table-column
                  prop="eventDesc"
                  label="告警描述"
                  width="250">
                </el-table-column>
                <el-table-column
                  prop="alarmTime"
                  label="告警时间"
                  width="220">
                </el-table-column>
                <el-table-column
                  prop="alarmValue"
                  label="告警值"
                  width="80">
                </el-table-column>
                <el-table-column
                  prop="isReturn"
                  label="复归" >
                  <template #default="{row}">
                    <span>{{ row.isReturn?'是':'否' }}</span>
                  </template>
                </el-table-column>
              </el-table>
            </template>
            <div class="fenye">
              <el-pagination
                background
                layout="prev, pager, next"
                :current-page.sync="pageobj._pageNo"
                @current-change="getdatalist"
                :total="+totalCount">
              </el-pagination>
            </div>
          </div>
    </div>
  </div>
</template>

<script>
import  {getgaojinlistapi} from '@/api/userscreen'
export default {
  name: 'CallPoliceAlarminformation',

  data() {
    return {
      pageobj: {
        _pageNo: 0,
        _pageSize: 10
      },
      loading:false,
      tableData:[],
      value1: [],
      totalCount: '',
      orgNo: '',
      orgType:''
    };
  },

  mounted() {
    this.gettime()
  },

  methods: {
    getmethods() {
      this.getdatalist () 
    },
    // 获取表格数据
    async getdatalist () {
      this.loading = true
      try {
        const res = await getgaojinlistapi({
        devId: this.$store.state.treedataobj.id, orgNo: this.orgNo, orgType: this.orgType,
        startDate: this.value1[0], endDate: this.value1[1], _pageNo: this.pageobj._pageNo - 1,
        _pageSize: this.pageobj._pageSize
      })
      this.totalCount = res.data.totalCount
      this.tableData = res.data.list
      } catch (error) {
        this.totalCount = '1'
      this.tableData = []
      }
      this.loading = false
    },
    // 获取当前时间戳
    gettime() {
      this.value1=[]
      const date = new Date()
      const year = date.getFullYear() // 年
      const month = date.getMonth() + 1 // 月
      const day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() //日
      this.value1.push(year + '-' + month + '-' + '01')
      this.value1.push(year+'-'+month+'-'+day)
    }
  },
};
</script>

<style lang="scss" scoped>
*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
.bigbox{
  height: 100%;
  .topbox{
  display: flex;
  justify-content: space-between;
  .button{
    button{
      width: 60px;
      height: 30px;
      background-color: #fff;
      border-radius: 3px;
      border: 1px solid #ccc;
      background-color: #1a90fe;
      color: #fff;
    }
  }
}
.bodybox{
  height: 97%;
  margin-top: 15px;
  .table{
    height: 90%;
    .fenye{
    text-align: right;
    margin-top: 15px;
  }
  }

}
}

</style>